package com.viphuli.app.tool.fragment;

import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import butterknife.Bind;

import com.loopj.android.http.RequestParams;
import com.offroader.utils.StringUtils;
import com.offroader.utils.ViewUtils;
import com.viphuli.app.tool.R;
import com.viphuli.app.tool.common.MyPageHelper;
import com.viphuli.app.tool.http.ApiRequest;

public class CircleHospitalAddFragment extends BaseProgressFragment {

	@Bind(R.id.id_update_info_item)
	protected TextView contentText;

	@Override
	protected int obtainContentRes() {
		return R.layout.frag_circle_hospital_add;
	}

	@Override
	protected void initParams() {

	}

	@Override
	protected void initView() {

	}

	@Override
	protected void initData() {

	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		if (StringUtils.isBlank(contentText.getText().toString())) {

			ViewUtils.toast("请输入医院名称");
			return false;
		}

		if (R.id.id_menu_hospital_info_add == item.getItemId()) {

			RequestParams params = new RequestParams();
			params.put("name", contentText.getText());//名称
			params.put("address_code", 1000);//北京

			ApiRequest.circleHospitalAdd.request(this, params);

			return true;
		}

		return false;
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getActivity().getMenuInflater().inflate(R.menu.menu_circle_hospital_info_save, menu);

		return true;
	}

	public static void go(Activity act) {
		MyPageHelper.circleHospitalAdd.showMyPage(act);
	}

}
